package com.teamin.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.validator.constraints.Length;
import org.springframework.validation.annotation.Validated;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 任务的实体类
 */
@Validated
@ApiModel("任务详情")
public class TaskEntity implements Serializable{

    @ApiModelProperty(value = "任务ID")
    private Long taskId;

    @ApiModelProperty(value = "任务名称")
    @Length(min = 0,max = 300, message = "任务的名称不能为空或长度不能大于300")
    private String taskName;

    @ApiModelProperty(value = "任务描述")
    @Length(min = 0,max = 2000,message = "任务的描述不能大于2000")
    private String description;

    @ApiModelProperty(value = "父任务ID")
    private Long parentTaskId;

    @ApiModelProperty(value = "父任务名称")
    private String parentTaskName;

    @ApiModelProperty(value = "任务状态0表示没完成1表示完成")
    private Integer stateId;

    @ApiModelProperty(value = "任务的创建时间")
    private Date createTime;

    @ApiModelProperty(value = "任务的更新时间")
    private Date updateTime;

    @ApiModelProperty(value = "任务结束时间")
    private Date planFinishTime;

    @ApiModelProperty(value = "任务删除时间")
    private Date closeTime;

    @ApiModelProperty(value = "任务的删除时间")
    private Date deleteTime;

    @ApiModelProperty(value = "任务是否被删除,0,表示没有被删除 ,1表示已删除")
    private Integer isdelete;

    @ApiModelProperty(value = "是否删除时间")
	private Integer isDeleteTime;

    @ApiModelProperty(value = "包含具体时间")
    private Integer isShowTime;

    @ApiModelProperty(value = "只读")
    private boolean readOnly;

    @ApiModelProperty(value = "评论的最后位置")
    private Integer commensLastId;

    @ApiModelProperty(value = "用户查看到评论的最后位置")
    private Integer commensUserLastId;

    @ApiModelProperty(value = "子任务的完成数量")
    private Integer subCompleted;

    @ApiModelProperty(value = "子任务的总量")
    private Integer subTotal;

    @ApiModelProperty(value = "任务提醒")
    private TaskRemindEntity taskRemind;


    public String getParentTaskName() {
        return parentTaskName;
    }

    public void setParentTaskName(String parentTaskName) {
        this.parentTaskName = parentTaskName;
    }

    public TaskRemindEntity getTaskRemind() {
        return taskRemind;
    }

    public void setTaskRemind(TaskRemindEntity taskRemind) {
        this.taskRemind = taskRemind;
    }

    private List<LabelEntity> labels;//标签

    private List<TaskEntity> subTask;//子任务

    public Integer getSubCompleted() {
        return subCompleted;
    }

    public Integer getSubTotal() {
        return subTotal;
    }

    public List<TaskEntity> getSubTask() {
        return subTask;
    }

    public void setSubCompleted(Integer subCompleted) {
        this.subCompleted = subCompleted;
    }

    public void setSubTotal(Integer subTotal) {
        this.subTotal = subTotal;
    }

    public void setSubTask(List<TaskEntity> subTask) {
        this.subTask = subTask;
    }

    public List<LabelEntity> getLabels() {
        return labels;
    }

    public void setLabels(List<LabelEntity> labels) {
        this.labels = labels;
    }

    public Integer getCommensLastId() {
        return commensLastId;
    }

    public Integer getCommensUserLastId() {
        return commensUserLastId;
    }

    public void setCommensLastId(Integer commensLastId) {
        this.commensLastId = commensLastId;
    }

    public void setCommensUserLastId(Integer commensUserLastId) {
        this.commensUserLastId = commensUserLastId;
    }

    public Long getParentTaskId() {
        return parentTaskId;
    }

    public void setParentTaskId(Long parentTaskId) {
        this.parentTaskId = parentTaskId;
    }

    @JsonIgnore
    private UserEntity assigner = new UserEntity(); //执行人
    @JsonIgnore
    private UserEntity creater = new UserEntity();//创建者

    private UserEntity closer = new UserEntity(); //任务关闭者
//    @JsonIgnore
    private Long assignerId;  //任务的执行者
//    @JsonIgnore
    private String assignerUserName;  //任务的执行者名称
//    @JsonIgnore
    private String assignerHeadIcon;  //任务的执行者头像
//    @JsonIgnore
    private Long createrId;    //任务的创建者ID
//    @JsonIgnore
    private String createrUserName;    //任务的创建者名称
//    @JsonIgnore
    private String createrHeadIcon;    //任务的创建者头像
    private List<CommentEntity> commentList = new ArrayList<CommentEntity>(); //评论

    private List<CommentEntity> simpleCommentList = new ArrayList<CommentEntity>(); //一部份评论

    public List<CommentEntity> getSimpleCommentList() {
        return simpleCommentList;
    }

    public void setSimpleCommentList(List<CommentEntity> simpleCommentList) {
        this.simpleCommentList = simpleCommentList;
    }

    private List<UserEntity> userList = new ArrayList<UserEntity>(); //关注着

    public TaskEntity(Long taskId, String taskName, String description, Date planFinishTime, Long assignerId, Long createrId) {
        this.taskId = taskId;
        this.taskName = taskName;
        this.description = description;
//        this.stateId = stateId;
//        this.createTime = createTime;
//        this.isdelete = isdelete;
        this.planFinishTime = planFinishTime;
        this.assignerId = assignerId;
        this.createrId = createrId;
    }

    public void setAssignerUserName(String assignerUserName) {
        this.assignerUserName = assignerUserName;
    }

    public void setAssignerHeadIcon(String assignerHeadIcon) {
        this.assignerHeadIcon = assignerHeadIcon;
    }

    public void setCreaterId(Long createrId) {
        this.createrId = createrId;
    }

    public void setCreaterUserName(String createrUserName) {
        this.createrUserName = createrUserName;
    }

    public void setCreaterHeadIcon(String createrHeadIcon) {
        this.createrHeadIcon = createrHeadIcon;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public String getAssignerUserName() {
        return assignerUserName;
    }

    public String getAssignerHeadIcon() {
        return assignerHeadIcon;
    }

    public Long getCreaterId() {
        return createrId;
    }

    public String getCreaterUserName() {
        return createrUserName;
    }

    public String getCreaterHeadIcon() {
        return createrHeadIcon;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public Long getTaskId() {
        return taskId;
    }

    public void setTaskId(Long taskId) {
        this.taskId = taskId;
    }

    public String getTaskName() {
        return taskName;
    }

    public void setTaskName(String taskName) {
        this.taskName = taskName;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description == null ? null : description.trim();
    }

    public Integer getStateId() {
        return stateId;
    }

    public void setStateId(Integer stateId) {
        this.stateId = stateId;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Integer getIsdelete() {
        return isdelete;
    }

    public void setIsdelete(Integer isdelete) {
        this.isdelete = isdelete;
    }

    public Date getPlanFinishTime() {
        return planFinishTime;
    }

    public void setPlanFinishTime(Date planFinishTime) {
        this.planFinishTime = planFinishTime;
    }

    public Long getAssignerId() {
        return assignerId;
    }

    public void setAssignerId(Long assignerId) {
        this.assignerId = assignerId;
    }

    public Date getDeleteTime() {
        return deleteTime;
    }

    public void setDeleteTime(Date deleteTime) {
        this.deleteTime = deleteTime;
    }

    public TaskEntity() {
    }

    @Override
    public String toString() {
        return "TaskEntity{" +
                "taskId=" + taskId +
                ", taskName='" + taskName + '\'' +
                ", description='" + description + '\'' +
                ", stateId=" + stateId +
                ", createTime=" + createTime +
                ", isdelete=" + isdelete +
                ", planFinishTime=" + planFinishTime +
                ", assignerId=" + assignerId +
                ", assignerUserName='" + assignerUserName + '\'' +
                ", assignerHeadIcon='" + assignerHeadIcon + '\'' +
                ", createrId=" + createrId +
                ", createrUserName='" + createrUserName + '\'' +
                ", createrHeadIcon='" + createrHeadIcon + '\'' +
                ", deleteTime=" + deleteTime +
                ", updateTime=" + updateTime +
                '}';
    }

	public List<CommentEntity> getCommentList() {
		return commentList;
	}

	public void setCommentList(List<CommentEntity> commentList) {
		this.commentList = commentList;
	}

	public List<UserEntity> getUserList() {
		return userList;
	}

	public void setUserList(List<UserEntity> userList) {
		this.userList = userList;
	}
	
	public Integer getIsShowTime() {
		return isShowTime;
	}

	public void setIsShowTime(Integer isShowTime) {
		if (isShowTime != null && isShowTime > 1) {
			isShowTime = 1;
		}
		this.isShowTime = isShowTime;
	}

	@JsonIgnore
	public Integer getIsDeleteTime() {
		return isDeleteTime;
	}

	public void setIsDeleteTime(Integer isDeleteTime) {
		this.isDeleteTime = isDeleteTime;
	}

	public Date getCloseTime() {
		return closeTime;
	}

	public void setCloseTime(Date closeTime) {
		this.closeTime = closeTime;
	}

	public UserEntity getCloser() {
		return closer;
	}

	public void setCloser(UserEntity closer) {
		this.closer = closer;
	}

	public UserEntity getAssigner() {
		return assigner;
	}

	public void setAssigner(UserEntity assigner) {
		this.assigner = assigner;
	}

	public UserEntity getCreater() {
		return creater;
	}

	public void setCreater(UserEntity creater) {
		this.creater = creater;
	}

	public boolean isReadOnly() {
		return readOnly;
	}

	public void setReadOnly(boolean readOnly) {
		this.readOnly = readOnly;
	}

	
}